/***************************************************************************
* ████████╗██████╗ ██╗ ██╗██████╗ ██████╗ ██████╗ ███╗ ███╗ *
* ╚══██╔══╝██╔══██╗ ██║ ██║██╔══██╗ ██╔════╝██╔═══██╗████╗ ████║ *
* ██║ ██████╔╝█████╗██║ █╗ ██║██████╔╝ ██║ ██║ ██║██╔████╔██║ *
* ██║ ██╔══██╗╚════╝██║███╗██║██╔═══╝ ██║ ██║ ██║██║╚██╔╝██║ *
* ██║ ██║ ██║ ╚███╔███╔╝██║ ██╗╚██████╗╚██████╔╝██║ ╚═╝ ██║ *
* ╚═╝ ╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ *
***************************************************************************/
// TR-WP.COM Framework
require_once(TEMPLATEPATH . '/admin/functions.php');
require_once(TEMPLATEPATH . '/admin/cs-framework.php');
require_once(TEMPLATEPATH . '/admin/tr-wp-plugins.php');
// require_once(TEMPLATEPATH . '/admin/tr-wp-security.php');
// TR-WP.COM Framework Activation Modules
define('CS_ACTIVE_FRAMEWORK', true);
define('CS_ACTIVE_METABOX', true);
define('CS_ACTIVE_TAXONOMY', true);
define('CS_ACTIVE_SHORTCODE', false);
define('CS_ACTIVE_CUSTOMIZE', false);
define('CS_ACTIVE_LIGHT_THEME', cs_get_option("tema_panel_color"));
// TR-WP.COM Option Class Converter 2023
function yoka($trwpcomconvertercsget) {
return cs_get_option($trwpcomconvertercsget);
}
// Navbar Fixed Fix
if (!is_user_id()) {
function tr_wp_head_logged_in_top_fix()
{ ?>
}
add_action('wp_head', 'tr_wp_head_logged_in_top_fix');
}
function admin_style() { ?>
}
add_action('admin_enqueue_scripts', 'admin_style');
// Theme Blocks
require_once(TEMPLATEPATH . '/inc/blocks.php');
// Create Pages
require_once(TEMPLATEPATH . '/inc/pages.php');
// Create Post Types
require_once(TEMPLATEPATH . '/inc/post-types.php');
// Register
require_once(TEMPLATEPATH . '/inc/register.php');
// Login
require_once(TEMPLATEPATH . '/inc/login.php');
// Reset
require_once(TEMPLATEPATH . '/inc/reset.php');
// MetaBox
require_once(TEMPLATEPATH . '/admin/tr-wp-meta-box.php');
// Like
require_once(TEMPLATEPATH . '/inc/like.php');
// Rating
require_once(TEMPLATEPATH . '/inc/rating.php');
// Post Status
require_once(TEMPLATEPATH . '/inc/post-status.php');
// Post Status
require_once(TEMPLATEPATH . '/functions-ek.php');
// Takvim OLD
// require_once(TEMPLATEPATH . '/inc/takvim.php');
// Create Menus
for ($i = 1; $i <= 4; $i++) {
register_nav_menu("footer_menu_" . $i, "Footer (Alt) Menü " . $i);
}
for ($i = 1; $i <= 4; $i++) {
register_nav_menu("header_mega_menu_uclu_" . $i, "Header (ÜST) Mega Menü Üçlü " . $i);
}
for ($i = 1; $i <= 4; $i++) {
register_nav_menu("header_mega_menu_dortlu_" . $i, "Header (ÜST) Mega Menü Dörtlü " . $i);
}
register_nav_menu("header_sub_menu", "Header (Sub) Menü");
register_nav_menu("footer_menu_bottom", "Footer (En Alt) Menü");
register_nav_menu("blog_menu", "Blog Sidebar (Sağ) Menü");
// Menuden fazla classları kaldırma.
function tr_wp_nav_menu_id_class_silici($var) {
return is_array($var) ? array_intersect($var, ['current-menu-item', 'menu-item-has-children', 'active']) : '';
}
add_filter('page_css_class', 'tr_wp_nav_menu_id_class_silici', 100, 1);
add_filter('nav_menu_item_id', 'tr_wp_nav_menu_id_class_silici', 100, 1);
add_filter('nav_menu_css_class', 'tr_wp_nav_menu_id_class_silici', 100, 1);
// Temiz menu fix
function trwp_menu_aria_sil($input) {
return preg_replace('/ (aria-current)="(.*?)"/', '', $input);
}
add_filter('wp_nav_menu', 'trwp_menu_aria_sil');
// Menu active class atama
add_filter('nav_menu_css_class', 'trwp_menu_aktif_klas', 10, 2);
function trwp_menu_aktif_klas($classes, $item) {
if (in_array('current-menu-item', $classes)) {
$classes[] = 'active';
}
return $classes;
}
/**************************/
/* BLOG DEFAULT POST TYPE */
/**************************/
function trwp_default_post_type_changer() {
global $menu;
global $submenu;
$menu[5][0] = 'Bungalovlar';
$submenu['edit.php'][5][0] = 'Bungalovlar';
$submenu['edit.php'][10][0] = 'Bungalov Ekle';
}
add_action('admin_menu', 'trwp_default_post_type_changer');
// Default post type icon değiştirme.
function trwp_default_post_type_icon() {
global $menu;
foreach ($menu as $key => $val) {
if (__('Bungalovlar', 'bungalovlar') == $val[0]) {
$menu[$key][6] = 'dashicons-store';
}
}
}
add_action('admin_menu', 'trwp_default_post_type_icon');
// Sayfalama
function sayfalama($pages = '', $range = 2) {
$showitems = ($range * 2) + 1;
global $paged;
if (empty($paged)) {
$paged = 1;
}
if ($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if (!$pages) {
$pages = 1;
}
}
if (1 != $pages) {
echo '
";
}
}
// Arşive Arama Sonuçları
function tr_wp_post_limit_archive_pages($query) {
if (is_admin() || !$query->is_main_query()) {
return;
}
if (is_post_type_archive('blog')) {
$query->set('posts_per_page', 1);
}
}
add_filter('pre_get_posts', 'tr_wp_post_limit_archive_pages');
// Bölgeler
function register_taxonomy_bolge() {
register_taxonomy(
'bolge',
'post',
[
'label' => __('Bölge'),
'hierarchical' => true,
'show_admin_column' => true,
]
);
}
add_action('init', 'register_taxonomy_bolge');
// Özellikler
function register_taxonomy_ozellik() {
register_taxonomy(
'ozellik',
'post',
[
'label' => __('Özellik'),
'hierarchical' => false,
'show_admin_column' => true,
]
);
}
add_action('init', 'register_taxonomy_ozellik');
// Adminbar Sil
add_action('after_setup_theme', 'all_user_remove_admin_bar');
function all_user_remove_admin_bar($adminbarsilinsinmi) {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
// Geri Dön Fonksiyonu
function get_back_page() {
$previous = "javascript:history.go(-1)";
if (isset($_SERVER['HTTP_REFERER'])) {
$previous = $_SERVER['HTTP_REFERER'];
}
return $previous;
}
// Taxonomy Listele
function get_tax_list($taxname) {
$args = [
'style' => 'none',
'separator' => '',
'show_count' => 0,
'child_of' => 0,
'title_li' => __(''),
'taxonomy' => $taxname,
];
wp_list_categories($args);
}
/* Kullanıcı Gerçek IP Alma */
if (!is_user_id()) {
function GetIP()
{
if (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} elseif (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
if (strstr($ip, ',')) {
$tmp = explode(',', $ip);
$ip = trim($tmp[0]);
}
} else {
$ip = getenv("REMOTE_ADDR");
}
return $ip;
}
function trwp_kullanici_giris_ip($user_login, $user)
{
$loginipsi = GetIP();
update_user_meta($user->ID, 'login_ip', $loginipsi);
}
add_action('wp_login', 'trwp_kullanici_giris_ip', 10, 2);
}
// Comment Count By User
function commentCount() {
global $wpdb, $current_user;
get_currentuserinfo();
$userId = $current_user->ID;
$count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM ' . $wpdb->comments . ' WHERE user_id = "' . $userId . '"');
return $count;
}
// Özel yorum şablonu.
function tr_wp_yorum_sablonu($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
$comment_title = get_comment_meta($comment->comment_ID, 'comment_title', true);
$konum = get_comment_meta($comment->comment_ID, 'konum', true);
$temizlik = get_comment_meta($comment->comment_ID, 'temizlik', true);
$hizmet = get_comment_meta($comment->comment_ID, 'hizmet', true);
$havuz = get_comment_meta($comment->comment_ID, 'havuz', true);
$konfor = get_comment_meta($comment->comment_ID, 'konfor', true);
$performans = get_comment_meta($comment->comment_ID, 'performans', true);
?>
$adi = get_comment_author(); ?>
}
// Yorumları yeniden eskiye göre sıralama.
function wpb_reverse_comments($comments) {
$comment_order = get_option('comment_order');
if ($comment_order == 'asc') {
return array_reverse($comments);
}
}
add_filter('comments_array', 'wpb_reverse_comments');
// Üye olunca otomatik yönlendirme.
add_filter('login_redirect', function () {
return site_url('profil');
});
// Yorum Puanlarını Veritabanından Getirme
function get_rating($post_id) {
global $wpdb;
$comments_table = $wpdb->prefix . 'comments';
$commentsmeta_table = $wpdb->prefix . 'commentmeta';
$get_post_comments = $wpdb->get_results("SELECT * FROM $comments_table WHERE comment_post_ID='$post_id'", OBJECT);
$ratings_array = [];
foreach ($get_post_comments as $comment) {
$query_reaction = $wpdb->get_results(
"SELECT * FROM $commentsmeta_table WHERE `comment_id`='$comment->comment_ID' AND `meta_key`='konum'",
OBJECT
);
foreach ($query_reaction as $reaction) {
if (!empty($reaction->meta_value)) {
$ratings_array[] = $reaction->meta_value;
}
}
}
if (count($ratings_array) > 0) {
$average = array_sum($ratings_array) / count($ratings_array);
$rating = round($average);
echo '';
} else {
echo '';
}
}
// Kullanıcılar sayfasına eklemeler.
$mt8_sulbpc = new Mt8_Sort_User_List_By_Post_Counts();
$mt8_sulbpc->register_hooks();
class Mt8_Sort_User_List_By_Post_Counts {
const TEXT_DOMAIN = 'mt8-sort-user-list-by-post-counts';
public function register_hooks() {
add_filter('manage_users_sortable_columns', [&$this, 'manage_users_sortable_columns']);
}
public function manage_users_sortable_columns($sortable_columns) {
if (!array_key_exists('posts', $sortable_columns)) {
$sortable_columns['posts'] = 'post_count';
}
return $sortable_columns;
}
}
// Count Rez
function rez_count($status, $userid) {
global $wpdb;
$count = $wpdb->get_var(
$wpdb->prepare(
"
SELECT COUNT(*)
FROM $wpdb->posts
WHERE post_type = 'rezervasyonlar' AND post_author = %d AND post_status = %s
",
$userid,
$status
)
);
return $count;
}
// Sahre (Paylaş)
function share() {
$adresss = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$trwpshareURL = urlencode(get_permalink());
$trwpshareBTNtitle = get_the_title();
?>
}
// Dolu odalar Json
function dolu_json($odaname, $postidx) {
global $wpdb, $post, $post_id;
$post_detay = get_post_meta($postidx, 'post_detay');
$odalar = $post_detay[0]['odalar'];
$dolu_tarihler = [];
foreach ($odalar as $oda) {
if ($oda['oda_adi'] === $odaname) {
foreach ($oda as $tarih => $fiyat) {
if (empty($fiyat) && preg_match('/\d{4}-\d{2}-\d{2}/', $tarih)) {
$dolu_tarihler[] = "'" . $tarih . "'";
}
$odax = $oda['oda_adi'];
}
}
}
if (empty($dolu_tarihler)) {
return ''; // eşleşen oda yoksa boş değer döndür
}
$dolu_tarihler_cikti = '[' . implode(',', $dolu_tarihler) . ']';
$dolu_tarihler_cikti = str_replace('"', '', $dolu_tarihler_cikti);
$dolu_tarihler_cikti = str_replace("'oda_adi',", "", $dolu_tarihler_cikti);
return $dolu_tarihler_cikti;
}
// Boş odalar Json
function bos_json() {
global $wpdb, $post_id;
$get_fiyatlar = get_post_meta($post_id, 'fiyatlar', $fiyatlar);
$get_fiyatlar = $get_fiyatlar[0];
$bos_tarihler = [];
foreach ($get_fiyatlar as $bos_tarih => $bos_fiyat) {
if (!empty($bos_fiyat)) {
// $bos_tarih[] = ' - ' . $bos_fiyat . '';
$bos_tarihler[] = $bos_tarih . $bos_fiyat;
}
}
}
// Son tarih kontrol
function son_tarih() {
global $wpdb, $post_id;
$get_fiyatlar = get_post_meta($post_id, 'fiyatlar', true);
$last_date = '';
$last_price = '';
foreach ($get_fiyatlar as $date => $price) {
if (!empty($price)) {
$last_date = $date;
$last_price = $price;
}
}
$last_date_convert = date('d-m-Y', strtotime($last_date));
echo $last_date_convert;
}
// Kullanıcı rollerini kontrol etme
function check_user_role() {
if (!is_user_logged_in() || (!current_user_can('admin') && !current_user_can('firma'))) {
// wp_redirect(get_permalink(yoka('page_giris')));
// exit;
header("Location: " . esc_url(get_permalink(yoka('page_giris'))) . "");
}
}
// Session start
function sess_start() {
if (!session_id())
session_start();
}
add_action('init','sess_start');
// Telefon formatlama
function format_telefon($telefon) {
if (substr($telefon, 0, 1) !== '0') {
$telefon = '0' . $telefon;
}
switch (strlen($telefon)) {
case 10:
$telefon = '90' . $telefon;
break;
case 11:
$telefon = '9' . $telefon;
break;
default:
break;
}
return $telefon;
}
// Rezervasyon ID Temizleme
function getRezId($rez_id) {
$rez_id = explode("-", $rez_id);
if (isset($rez_id[1])) {
$rez_id = $rez_id[1];
return $rez_id;
}
}
echo $adi; ?> printf( __('%1$s'), get_comment_date(), get_comment_time() ); ?>
Konum:
} ?> if ($temizlik) { ?>Temizlik:
} ?> if ($hizmet) { ?>Hizmet:
} ?> if ($havuz) { ?>Havuz/Jakuzi:
} ?> if ($konfor) { ?>Konfor:
} ?> if ($performans) { ?>Fiyat/Performans:
} ?>